package com.hkts.naturalgasauthentication.mobile.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hkts.naturalgasauthentication.base.dao.ManagementBaseDao;
import com.hkts.naturalgasauthentication.base.dao.mapper.UserMobileMapper;
import com.hkts.naturalgasauthentication.mobile.dao.UserMobileDao;
import com.hkts.naturalgasauthentication.mobile.entity.UserMobiles;
import com.hkts.naturalgasauthentication.mobile.service.UserMobileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Example;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassNameUserMobileServiceImpl
 * @Description
 * @Author yck
 * @Date2021-05-11 13:56
 * @Version V1.0
 **/
@Service
public class UserMobileServiceImpl implements UserMobileService {
    @Autowired
    private UserMobileDao userMobileDao;
    @Override
    public ManagementBaseDao getRepository() {
        return userMobileDao;
    }

    @Autowired
    private UserMobileMapper userMobileMapper;
    @Override
    public List<UserMobiles> getUserMobilesByUserId(String userId) {
        /*UserMobiles user=new UserMobiles();
        user.setUserId(userId);
        user.setId(null);
        Example<UserMobiles> example=Example.of(user);
        List<UserMobiles> all = userMobileDao.findAll(example);*/
        QueryWrapper<UserMobiles> query=new QueryWrapper<UserMobiles>();
        query.lambda().eq(UserMobiles::getUserId,userId);
        List<UserMobiles> all = userMobileMapper.selectList(query);
        return all;
    }

    public UserMobiles findByMobile(String mobile){
        return userMobileDao.findByMobile(mobile);
    }
}
